package Operation;

import Books.Book;
import Books.Booklist;

import java.util.Scanner;

public class Returnbook implements IOPeration{
    @Override
    public void work(Booklist booklist) {
        System.out.println("归还图书");
        System.out.println("请输入你要归还的图书");
        Scanner scanner=new Scanner(System.in);
        String name= scanner.nextLine();
        int n=booklist.getUsersize();
        for(int i=0;i<n;i++){
            Book book=booklist.getbook(i);
            if(book.getBname().equals(name)){//是否找到该书籍
                if(!book.isBrorrowed()){
                    System.out.println("你要找的书，没有被借阅不需要归还");
                }
                else {
                    book.setBrorrowed(false);
                    System.out.println("归还成功");
                    System.out.println(book);
                }
                return;
            }
        }
    }
}
